<?php
 mb_internal_encoding("utf-8");
 require "../document/class_corpus.php";
 require "../document/class_document.php";
 require "../document/class_document_xml.php";

 require "../files/tool_files_dirs.php";

 require "../misc/class_tag.php";

 require "../tree/class_tree.php";
 require "../tree/class_tree_xhtml.php";
 require "../tree/class_structure.php";
 require "../tree/tool_tree.php";

 require "../array/tool_array.php";

 require "../maths/tool_maths.php";
 require "../pear_graph/tool_pear_graph.php";

 require "./tool_string.php";
 require "./class_segment.php";

 $corpus=tool_corpus::get_corpus_regexp("../xml/europa/","555.fr.xml");
// $corpus=tool_corpus::get_corpus_regexp("../xml/europa/",".fr.xml");
// $corpus=tool_corpus::get_corpus_regexp("../xml/test/",".fr.xml");
 $array_doc=$corpus->__get_array_doc();
// $document=$array_doc[0];
// echo count($array_doc);
//die();

//die();

$factory_mot=new factory_mot();
$res_x=$res_y=array();
foreach($array_doc as $document){
  $structure=$document->__get_structure();
  $signature=$structure->__get_signature();
  tool_tree::cleanstructure(&$signature);
  $signature->__recalc_idn();
  $test=new RecursiveIteratorIterator($signature,RecursiveIteratorIterator::SELF_FIRST);
//  $mb_len=0;
    foreach($test as $bloc_xhtml){
      $texte=tool_tree::tree_xhtml2texte($bloc_xhtml->__get_value());
      $id=$factory_mot->get_all_mots($texte);
//      $mb_len+=mb_strlen($texte);
    }
 }
$factory_mot->init_etiquetage();
$factory_mot->init_chunk();

//$repartition_chunk=$factory_mot->__get_repartiton_chunk();
$repartition_segment=$factory_mot->__get_repartition_segment();

$res_v=$res_all=$res_p=$res_i=array();
foreach($repartition_segment as $id_bloc){
  foreach($id_bloc as $array_id_segment){
    foreach($array_id_segment as $id_segment){
      $mot=$factory_mot->__get_word($id_segment);
      $len=$mot->__get_len();
      $type=$mot->__get_attribute("type");
       if($type=="v") $res_v[$len]++;
       if($type=="p") $res_p[$len]++;
       if($type=="i") $res_i[$len]++;
       $res_all[$len]++;
    }
  }
}
ksort($res_all);
ksort($res_v);
ksort($res_p);
ksort($res_i);
//print_r($res_i);
//die();
$tool_graph=new Tool_pear_graph();
$tool_graph->__add_array_x(array_keys($res_all));
$tool_graph->__add_array_y(array_values($res_all));
$tool_graph->__add_plot_title("all");
$tool_graph->__add_array_x(array_keys($res_v));
$tool_graph->__add_array_y(array_values($res_v));
$tool_graph->__add_plot_title("vide");
$tool_graph->__add_array_x(array_keys($res_p));
$tool_graph->__add_array_y(array_values($res_p));
$tool_graph->__add_plot_title("plein");
$tool_graph->__add_array_x(array_keys($res_i));
$tool_graph->__add_array_y(array_values($res_i));
$tool_graph->__add_plot_title("inconnu");
/*
*/
$graph=$tool_graph->plot03();
$graph->done();
?>
